/*
 * VariableStringSerializer.h
 *
 *  Created on: Oct 23, 2012
 *      Author: m
 */

#ifndef VARIABLESTRINGSERIALIZER_H_
#define VARIABLESTRINGSERIALIZER_H_

#include <cassert>
#include <string>
#include <cstring>
#include "Serializer.h"

namespace physical
{

class VariableStringSerializer: public Serializer<std::string>
{
private:
    typedef unsigned char str_size_t;

public:
    VariableStringSerializer();

    ~VariableStringSerializer();

    // Métodos para serializacion y deserializacion estática
    size_t serialize( const std::string &element, byteStream block );
    size_t deserialize( const byteStream block, std::string &element );
    size_t getSize( const std::string &element );



    /*************************************************************
     **********************   Exepciones   **********************
     *************************************************************/

    /**
     * Excepcion que indica que el string a serializar tiene una longitud
     *  mayor a 255 caracteres.
     */
    class StringIsTooLongException: public PhysicalException
    {
        virtual const char* what() const throw()
        {
          return "String Length is greater than 255.";
        }
    };

};

} /* namespace physical */
#endif /* VARIABLESTRINGSERIALIZER_H_ */
